<?php

Yii::import('common.models._base.BaseTrainerProfileReview');

class TrainerProfileReview extends BaseTrainerProfileReview {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public static function getAllReviewTrainnerprofile($userId) {
        return $reviewdetails = TrainerProfileReview::model()->findAllbyAttributes(array('to_user_id' => $userId));
    }

    public static function trainerResponseRate($type, $classCourseId) {
        $criteria = new CDbCriteria;
        $criteria->condition = $type . '=' . $classCourseId;
        $totalEnqury = count(MakeQuery::model()->findAll($criteria));
        if ($totalEnqury >= 1) {
            $totalReplyEnqury = count(MakeQuery::model()->findAll($type = $classCourseId . ' AND mail_sent=1'));
            $totalResponse = ($totalReplyEnqury / $totalEnqury) * 100;
            return ceil($totalResponse) . ' %';
        } else {
            return'No Query !';
        }
    }

}